function UserBcjkh() {
    this.form = this.InitForm();
    this.table = this.InitTable();
    // this.InitOrg();
    this.pdfData();
}

UserBcjkh.prototype.InitForm = function () {
    var form;
    $("#year").val($("#hidyear").val());
    layui.use('form', function () {
        form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        // 选择框事件，去掉
        // form.on('select(year)', function (data) {
        //    vDSOPayDeptsh.searchtable();
        // });
        // form.on('select(orgid)', function (data) {
        //    vDSOPayDeptsh.searchtable();
        // });

        form.render();
    });
    return form;
}

UserBcjkh.prototype.pdfData = function () {
    var hidtablehight;
    var html = "房山公安分局" + $('#hiddeptname').val()+" ";
    var quarter = $('input[name="quarter"]:checked ').val();

    html += $('#year').val() + "年第" + quarter + "季度补贴"
    $('.orgname').html(html)


    var month1 = "一月";
    var month2 = "二月";
    var month3 = "三月";
    if (quarter == 2) {
        month1 = "四月";
        month2 = "五月";
        month3 = "六月"
    }
    if (quarter == 3) {
        month1 = "七月";
        month2 = "八月";
        month3 = "九月"
    }
    if (quarter == 4) {
        month1 = "十月";
        month2 = "十一月";
        month3 = "十二月"
    }

    $("#rmonth1").text(month1);
    $("#rmonth2").text(month2);
    $("#rmonth3").text(month3);

    $("#omonth1").text(month1);
    $("#omonth2").text(month2);
    $("#omonth3").text(month3);

    $("#day1").text(month1+'月值勤天数（每月最高30天）');
    $("#day12").text(month2+'月值勤天数（每月最高30天）');
    $("#day13").text(month3+'月值勤天数（每月最高30天）');

    $("#day2").text(month1+'值勤天数（每月最高26天）');
    $("#day22").text(month2+'值勤天数（每月最高26天）');
    $("#day23").text(month3+'值勤天数（每月最高26天）');
    var year = $("#year").val();

    $.ajax({
        type: "POST",
        url: "get_deptsw_dept_sh_list",
        data: {
            year: year,
            quarter: quarter,
            page: 1,
            limit: 1000
        },
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')').data;
                $("#tableData tbody").html("");
                for (var i = 0; i < data.length; i++) {
                    var tr = "<tr><td>" + (i + 1) + "</td>";
                    tr += "<td>" + data[i].realname + "</td>";
                    tr += "<td>" + data[i].orgname + "</td>";
                    tr += "<td>" + data[i].cardno + "</td>";
                    tr += "<td>" + data[i].summoney + "</td>";
                    tr += "<td>" + data[i].dutynumsum + "</td>";
                    tr += "<td>" + data[i].dutynumday1 + "</td>";
                    tr += "<td>" + (data[i].dutynum1 == null ? ' ' : data[i].dutynum1) + "</td>";
                    tr += "<td>" + data[i].dutynumday12 + "</td>";
                    tr += "<td>" + (data[i].dutynum12 == null ? ' ' : data[i].dutynum12) + "</td>";
                    tr += "<td>" + data[i].dutynumday13 + "</td>";
                    tr += "<td>" + (data[i].dutynum13 == null ? ' ' : data[i].dutynum13) + "</td>";
                    tr += "<td>" + data[i].dutynumday2 + "</td>";
                    tr += "<td>" + (data[i].dutynum2 == null ? ' ' : data[i].dutynum2) + "</td>";
                    tr += "<td>" + data[i].dutynumday22 + "</td>";
                    tr += "<td>" + (data[i].dutynum22 == null ? ' ' : data[i].dutynum22) + "</td>";
                    tr += "<td>" + data[i].dutynumday23 + "</td>";
                    tr += "<td>" + (data[i].dutynum23 == null ? ' ' : data[i].dutynum23) + "</td>";
                    tr += "<td>" + data[i].retainnumsum + "</td>";
                    tr += "<td>" + data[i].retainnum1 + "</td>";
                    tr += "<td>" + data[i].retainnum2 + "</td>";
                    tr += "<td>" + data[i].retainnum3 + "</td>";
                    tr += "<td>" + data[i].overtimenumsum + "</td>";
                    tr += "<td>" + data[i].overtimenum1 + "</td>";
                    tr += "<td>" + data[i].overtimenum2 + "</td>";
                    tr += "<td>" + data[i].overtimenum3 + "</td>";
                    tr += "<td> </td>";
                    tr += "<td>" + (data[i].remark == null ? ' ' : data[i].remark) + "</td></tr>";
                    $('#tableData').append(tr);
                  }
            // }
            // hidtablehight =  data.length * 35;
            // $('#tablehight').val(hidtablehight) ;
        },
        complete: function (XHR) {
            top.mylayui.closeAll('loading');
        },
        error: function () {

        }
    });
}

function getstatu(statu) {
    var text = statu;
    var ret = "";
    if (text == "0") {
        ret = '保存';
    }
    else if (text == "1") {
        ret = '发布';
    }
    else if (text == "2") {
        ret = '确认';
    }
    else if (text == "3") {
        ret = '归档';
    }
    else if (text == "4"||text=="5") {
        ret = '驳回';
    }
    return ret;
}


UserBcjkh.prototype.InitTable = function () {
    var table;
    var _this = this;
    layui.use('table', function () {
        var quarter = $('input[name="quarter"]:checked ').val();
        var month1 = "一月";
        var month2 = "二月";
        var month3 = "三月";
        if (quarter == 2) {
            month1 = "四月";
            month2 = "五月";
            month3 = "六月"
        }
        if (quarter == 3) {
            month1 = "七月";
            month2 = "八月";
            month3 = "九月"
        }
        if (quarter == 4) {
            month1 = "十月";
            month2 = "十一月";
            month3 = "十二月"
        }

        table = layui.table;
        table.render({
            elem: '#list'
            , height: $(window).height() - 140
            , url: 'get_deptsw_dept_sh_list' // 数据接口
            , page: true // 开启分页
            , limit: 40
            , id: 'vtdpuserlist'
            , limits: [20, 40, 80, 100]
            , method: "post"
            , cols: [[ // 表头
                {field: 'realname', title: '姓名', width: 120, align: 'center', rowspan: 3, fixed: 'left'}
                , {field: 'orgname', title: '部门', width: 120, align: 'center', rowspan: 3}
                , {field: 'cardno', title: '身份证号', width: 180, align: 'center', rowspan: 3}
                , {field: 'status', title: '状态', width: 100, align: 'center', rowspan: 3}
                , {field: 'summoney', title: '合计', width: 180, align: 'center', rowspan: 3}
                , {title: '执勤岗位津贴', align: 'center', colspan: 13}
                , {title: '季度保留津贴', align: 'center', colspan: 4}
                , {title: '加班补贴', align: 'center', colspan: 4}
                , {field: 'remark', title: '备注', width: 180, align: 'center', rowspan: 3, edit: 'text'}
            ],
                [
                    {field: 'dutynumsum', title: '值勤岗位津贴合计', width: 180, align: 'center', rowspan: 2}
                    , {title: '一类岗执行50元标准', width: 100, align: 'center', colspan: 6}
                    , {title: '二类岗执行40元标准', width: 100, align: 'center', colspan: 6}
                    , {field: 'retainnumsum', title: '保留津贴合计', width: 180, align: 'center', rowspan: 2}
                    , {
                    field: 'retainnum1',
                    title: '' + month1 + '',
                    width: 180,
                    align: 'center',
                    rowspan: 2
                }
                    , {
                    field: 'retainnum2',
                    title: '' + month2 + '',
                    width: 180,
                    align: 'center',
                    rowspan: 2
                }
                    , {
                    field: 'retainnum3',
                    title: '' + month3 + '',
                    width: 180,
                    align: 'center',
                    rowspan: 2
                }
                    , {field: 'overtimenumsum', title: '加班补贴合计', width: 180, align: 'center', rowspan: 2}
                    , {
                    field: 'overtimenum1',
                    title: '' + month1 + '',
                    width: 180,
                    align: 'center',
                    rowspan: 2
                }
                    , {
                    field: 'overtimenum2',
                    title: '' + month2 + '',
                    width: 180,
                    align: 'center',
                    rowspan: 2
                }
                    , {
                    field: 'overtimenum3',
                    title: '' + month3 + '',
                    width: 180,
                    align: 'center',
                    rowspan: 2
                }
                ],
                [
                    {field: 'dutynumday1', title: month1+'（每月最高30天）', width: 180, align: 'center'}
                    , {field: 'dutynum1', title: '金额', width: 80, align: 'center'}
                    , {field: 'dutynumday12', title: month2+'（每月最高30天）', width: 180, align: 'center'}
                    , {field: 'dutynum12', title: '金额', width: 80, align: 'center'}
                    , {field: 'dutynumday13', title: month3+'（每月最高30天）', width: 180, align: 'center'}
                    , {field: 'dutynum13', title: '金额', width: 80, align: 'center'}
                    , {field: 'dutynumday2', title: month1+'（每月最高26天）', width: 180, align: 'center'}
                    , {field: 'dutynum2', title: '金额', width: 80, align: 'center'}
                    , {field: 'dutynumday22', title: month2+'（每月最高26天）', width: 180, align: 'center'}
                    , {field: 'dutynum22', title: '金额', width: 80, align: 'center'}
                    , {field: 'dutynumday23', title: month3+'（每月最高26天）', width: 180, align: 'center'}
                    , {field: 'dutynum23', title: '金额', width: 80, align: 'center'}
                ]
            ]
            , request: {
                type: 'post'
            }
            , where: {
                year: $("#year").val(),
                quarter: $('input[name="quarter"]:checked ').val()
            }
            , done: function (res, page, count) {
                var dataarr = res.data;
                var orgname ="";
                if(dataarr.length != 0){
                    var status = dataarr[0].status;
                    console.log(status);
                    if(status == 1){
                        $('#passbnt').show();
                        $("#restbnt").show();
                    }else{
                        $('#passbnt').hide();
                        $("#restbnt").hide();
                    }
                    if(status == 2 || status == 3)
                    {
                        $('#pdfbutton').show();
                    }else
                    {
                        $('#pdfbutton').hide();
                    }
                    orgname = dataarr[0].orgname;
                }

                // var year = $("#year").val();
                // var quarter = $('input[name="quarter"]:checked ').val();
                // $("#title").html("(" + orgname + "）单位" + year + "年第" + quarter + "季度值勤岗位津贴、季度保留津贴及加班补贴发放表");
                $("[data-field='status']").children().each(function (index) {
                    var text = $(this).text();
                    if (text == "0") {
                        $(this).text('保存')
                    }
                    else if (text == "1") {
                        $(this).text('确认')
                    }
                    else if (text == "2") {
                        $(this).text('发布')
                    }
                    else if (text == "3") {
                        $(this).text('归档')
                    }
                    else if (text == "4") {
                        $(this).text('驳回')
                    }
                })
            }
        });
    });
    return table;
}

UserBcjkh.prototype.searchtable = function () {
    var quarter = $('input[name="quarter"]:checked ').val();
    var month1 = "一月";
    var month2 = "二月";
    var month3 = "三月";
    if (quarter == 2) {
        month1 = "四月";
        month2 = "五月";
        month3 = "六月"
    }
    if (quarter == 3) {
        month1 = "七月";
        month2 = "八月";
        month3 = "九月"
    }
    if (quarter == 4) {
        month1 = "十月";
        month2 = "十一月";
        month3 = "十二月"
    }
    this.table.reload('vtdpuserlist', {
        cols: [[ // 表头
            {
                field: 'realname',
                title: '姓名',
                width: 120,
                align: 'center',
                rowspan: 3,
                fixed: 'left',
                templet: '#realnameTpl'
            }
            , {field: 'orgname', title: '部门', width: 120, align: 'center', rowspan: 3}
            , {field: 'cardno', title: '身份证号', width: 180, align: 'center', rowspan: 3}
            , {field: 'status', title: '状态', width: 100, align: 'center', rowspan: 3}
            , {field: 'summoney', title: '合计', width: 180, align: 'center', rowspan: 3}
            , {title: '执勤岗位津贴', align: 'center', colspan: 13}
            , {title: '季度保留津贴', align: 'center', colspan: 4}
            , {title: '加班补贴', align: 'center', colspan: 4}
            , {field: 'remark', title: '备注', width: 180, align: 'center', rowspan: 3, edit: 'text'}
        ],
            [
                {field: 'dutynumsum', title: '值勤岗位津贴合计', width: 180, align: 'center', rowspan: 2}
                , {title: '一类岗执行50元标准', width: 100, align: 'center', colspan: 6}
                , {title: '二类岗执行40元标准', width: 100, align: 'center', colspan: 6}
                , {field: 'retainnumsum', title: '保留津贴合计', width: 180, align: 'center', rowspan: 2}
                , {field: 'retainnum1', title: '' + month1 + '', width: 180, align: 'center', rowspan: 2}
                , {field: 'retainnum2', title: '' + month2 + '', width: 180, align: 'center', rowspan: 2}
                , {field: 'retainnum3', title: '' + month3 + '', width: 180, align: 'center', rowspan: 2}
                , {field: 'overtimenumsum', title: '加班补贴合计', width: 180, align: 'center', rowspan: 2}
                , {
                field: 'overtimenum1',
                title: '' + month1 + '',
                width: 180,
                align: 'center',
                rowspan: 2
            }
                , {
                field: 'overtimenum2',
                title: '' + month2 + '',
                width: 180,
                align: 'center',
                rowspan: 2
            }
                , {
                field: 'overtimenum3',
                title: '' + month3 + '',
                width: 180,
                align: 'center',
                rowspan: 2
            }
            ],
            [
                {field: 'dutynumday1', title: month1+'（每月最高30天）', width: 180, align: 'center'}
                , {field: 'dutynum1', title: '金额', width: 80, align: 'center'}
                , {field: 'dutynumday12', title: month2+'（每月最高30天）', width: 180, align: 'center'}
                , {field: 'dutynum12', title: '金额', width: 80, align: 'center'}
                , {field: 'dutynumday13', title: month3+'（每月最高30天）', width: 180, align: 'center'}
                , {field: 'dutynum13', title: '金额', width: 80, align: 'center'}
                , {field: 'dutynumday2', title: month1+'（每月最高26天）', width: 180, align: 'center'}
                , {field: 'dutynum2', title: '金额', width: 80, align: 'center'}
                , {field: 'dutynumday22', title: month2+'（每月最高26天）', width: 180, align: 'center'}
                , {field: 'dutynum22', title: '金额', width: 80, align: 'center'}
                , {field: 'dutynumday23', title: month3+'（每月最高26天）', width: 180, align: 'center'}
                , {field: 'dutynum23', title: '金额', width: 80, align: 'center'}
            ]
        ]
        , page: {
            curr: 1 //重新从第 1 页开始
        }
        , where: {
            year: $("#year").val(),
            quarter: $('input[name="quarter"]:checked ').val(),
            orgid: $("#hidorgid").val()
        }
    });

    this.pdfData();
}

UserBcjkh.prototype.tableref = function () {
    this.table.reload('vtdpuserlist', {
        where: {
            year: $("#year").val(),
            month: $("#month").val(),
            orgid: $("#hidorgid").val()
        }
    });
}

UserBcjkh.prototype.export = function () {
    top.ShowZheZhao();
    var year = $("#year").val();
    var quarter = $("#quarter").val();
    $.ajax({
        type: "POST",
        url: "deptsw_pay_export",
        data: {year: year, month: month, owner: 0},
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                window.open(data.msg, '_self');
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
        },
        complete: function (XHR) {
            top.ShowZheZhao();
        },
        error: function () {
        }
    });
}

UserBcjkh.prototype.addresult = function (result, msg) {
    if (result > 0) {
        top.mylayui.msg('操作成功', {icon: 1});
        top.mylayui.closeAll('iframe');
        vDSOPayDeptsh.searchtable();
    }
    else {
        if (msg) {
            top.mylayui.msg(msg, {icon: 0});
        } else {
            top.mylayui.msg('操作失败', {icon: 0});
        }
    }
}

var ijvDSOPayDeptsh;
$(function () {
    vDSOPayDeptsh = new UserBcjkh();
})


UserBcjkh.prototype.update = function (status) {
    var tabledataJson = this.table.cache;
    var year = $("#year").val();
    var quarter = $('input[name="quarter"]:checked ').val();
    tabledataJson['year'] = year;
    tabledataJson['quarter'] = quarter;
    tabledataJson['status'] = status;
    tabledataJson = JSON.stringify(tabledataJson);
    tabledataJson = tabledataJson.replace(/LAY_TABLE_INDEX/g, 'lay_TABLE_INDEX');

    top.mylayui.confirm('确定要提交吗？', {icon: 0}, function (index, dd) {
        top.mylayui.close(index);
        $.ajax({
            type: "POST",
            url: "deptsw_pay_update",
            contentType: 'application/json',
            data: tabledataJson,
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')');
                if (data.result > 0) {
                    top.mylayui.msg(data.msg, {icon: 1});
                    if (status == 2) vDSOPayDeptsh.createpdf();
                }
                else {
                    top.mylayui.msg(data.msg, {icon: 0});
                }
            },
            complete: function (XHR) {
            },
            error: function (XHR, errorText, errorType) {
                var res = XHR.responseText;
                top.mylayui.msg('操作失败', {icon: 0});
            }
        });
    })
}




UserBcjkh.prototype.createpdf = function () {
    var tabledataJson = this.table.cache;
    var year = $("#year").val();
    var quarter = $('input[name="quarter"]:checked ').val();
    var username = $("#hidusername").val();
    var nowtime = year + "年" + quarter + "季";
    var targetDom = $("#table");
    $('#tablehight').val(targetDom.height()) ;

    watermark({watermark_txt: username + "  " + nowtime});

    //把需要导出的pdf内容clone一份，这样对它进行转换、微调等操作时才不会影响原来界面
    var copyDom = targetDom.clone();
    //新的div宽高跟原来一样，高度设置成自适应，这样才能完整显示节点中的所有内容（比如说表格滚动条中的内容）
    copyDom.width(targetDom.width() + "px");
    copyDom.height(targetDom.height() + "px");
    copyDom.css('display', 'block');
    copyDom.css({
        "background-color": "white",
        "position": "absolute",
        "top": "600px",
        "z-index": "-1",
        "height": targetDom.height()
    });
    $('body').append(copyDom);
    svg2canvas(copyDom);
    html2canvas(copyDom, {
        onrendered: function (canvas) {
            var imgData = canvas.toDataURL('image/jpeg');
            var img = new Image();
            img.src = imgData;

            // img.src = 'http://127.0.0.1:8080/1.pdf';
            //根据图片的尺寸设置pdf的规格，要在图片加载成功时执行，之所以要*0.225是因为比例问题
            img.onload = function () {
                //此处需要注意，pdf横置和竖置两个属性，需要根据宽高的比例来调整，不然会出现显示不完全的问题
                if (this.width > this.height) {
                    var doc = new jsPDF('l', 'mm', [this.width * 0.225,
                        this.height * 0.225
                    ]);
                } else {
                    var doc = new jsPDF('p', 'mm', [this.width * 0.225,
                        this.height * 0.225
                    ]);
                }
                doc.addImage(imgData, 'jpeg', 0, 0, this.width * 0.225,
                    this.height * 0.225);
                //根据下载保存成不同的文件名

                $.ajax({
                    type: "POST",
                    url: "createPDF",
                    data: {
                        file: doc.output("datauristring"),
                        year: $('#year').val(),
                        quarter: $('input[name="quarter"]:checked ').val(),


                    },
                    beforeSend: function (XHR) {

                    },
                    success: function (data) {


                    },
                    complete: function (XHR) {

                    },
                    error: function () {

                    }
                });


                console.log(doc.output("datauristring"))
                // doc.save('pdf_' + new Date().getTime() + '.pdf');
            };
            //删除复制出来的div
            copyDom.remove();
        },
        background: "#fff",

        //这里给生成的图片默认背景，不然的话，如果你的html根节点没设置背景的话，会用黑色填充。
        allowTaint: true //避免一些不识别的图片干扰，默认为false，遇到不识别的图片干扰则会停止处理html2canvas
    });

    function watermark(settings) {
        //默认设置
        var defaultSettings = {
            watermark_txt: "text",
            watermark_x: 20,//水印起始位置x轴坐标
            watermark_y: 20,//水印起始位置Y轴坐标
            watermark_rows: 0,//水印行数
            watermark_cols: 20,//水印列数
            watermark_x_space: 100,//水印x轴间隔
            watermark_y_space: 50,//水印y轴间隔
            watermark_color: '#aaa',//水印字体颜色
            watermark_alpha: 0.6,//水印透明度
            watermark_fontsize: '15px',//水印字体大小
            watermark_font: '微软雅黑',//水印字体
            watermark_width: 210,//水印宽度
            watermark_height: 80,//水印长度
            watermark_angle: 15//水印倾斜度数
        };
        //采用配置项替换默认值，作用类似jquery.extend
        if (arguments.length === 1 && typeof arguments[0] === "object") {
            var src = arguments[0] || {};
            for (key in src) {
                if (src[key] && defaultSettings[key] && src[key] === defaultSettings[key])
                    continue;
                else if (src[key])
                    defaultSettings[key] = src[key];
            }
        }

        var oTemp = document.createDocumentFragment();

        //获取页面最大宽度
        var page_width = Math.max(document.body.scrollWidth, document.body.clientWidth);
        var cutWidth = page_width * 0.0150;
        var page_width = page_width - cutWidth;
        //获取页面最大高度
        // console.log( $('#tablehight').val());
        var page_height = parseInt($('#tablehight').val());
        // var tableheightMin = Math.max(document.body.scrollHeight, document.body.clientHeight) + 450;
        // if(tableheightMin > page_height) page_height = tableheightMin;
        //var page_height = Math.max(document.body.scrollHeight, document.body.clientHeight) + 450;
        // var page_height = document.body.scrollHeight+document.body.scrollTop;
        console.log(page_height);
        //如果将水印列数设置为0，或水印列数设置过大，超过页面最大宽度，则重新计算水印列数和水印x轴间隔
        if (defaultSettings.watermark_cols == 0 || (parseInt(defaultSettings.watermark_x + defaultSettings.watermark_width * defaultSettings.watermark_cols + defaultSettings.watermark_x_space * (defaultSettings.watermark_cols - 1)) > page_width)) {
            defaultSettings.watermark_cols = parseInt((page_width - defaultSettings.watermark_x + defaultSettings.watermark_x_space) / (defaultSettings.watermark_width + defaultSettings.watermark_x_space));
            defaultSettings.watermark_x_space = parseInt((page_width - defaultSettings.watermark_x - defaultSettings.watermark_width * defaultSettings.watermark_cols) / (defaultSettings.watermark_cols - 1));
        }
        //如果将水印行数设置为0，或水印行数设置过大，超过页面最大长度，则重新计算水印行数和水印y轴间隔
        if (defaultSettings.watermark_rows == 0 || (parseInt(defaultSettings.watermark_y + defaultSettings.watermark_height * defaultSettings.watermark_rows + defaultSettings.watermark_y_space * (defaultSettings.watermark_rows - 1)) > page_height)) {
            defaultSettings.watermark_rows = parseInt((defaultSettings.watermark_y_space + page_height - defaultSettings.watermark_y) / (defaultSettings.watermark_height + defaultSettings.watermark_y_space));
            defaultSettings.watermark_y_space = parseInt(((page_height - defaultSettings.watermark_y) - defaultSettings.watermark_height * defaultSettings.watermark_rows) / (defaultSettings.watermark_rows - 1));
        }
        var x;
        var y;
        console.log(defaultSettings.watermark_rows);
        for (var i = 0; i < defaultSettings.watermark_rows; i++) {
            y = defaultSettings.watermark_y + (defaultSettings.watermark_y_space + defaultSettings.watermark_height) * i;
            for (var j = 0; j < defaultSettings.watermark_cols; j++) {
                x = defaultSettings.watermark_x + (defaultSettings.watermark_width + defaultSettings.watermark_x_space) * j;

                var mask_div = document.createElement('div');
                mask_div.id = 'mask_div' + i + j;
                mask_div.className = 'mask_div';
                mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
                //设置水印div倾斜显示
                mask_div.style.webkitTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.MozTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.msTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.OTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.transform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.visibility = "";
                mask_div.style.position = "absolute";
                mask_div.style.left = x + 'px';
                mask_div.style.top = y + 'px';
                mask_div.style.overflow = "hidden";
                mask_div.style.zIndex = "9999";
                mask_div.style.pointerEvents = 'none';//pointer-events:none  让水印不遮挡页面的点击事件
                //mask_div.style.border="solid #eee 1px";
                mask_div.style.opacity = defaultSettings.watermark_alpha;
                mask_div.style.fontSize = defaultSettings.watermark_fontsize;
                mask_div.style.fontFamily = defaultSettings.watermark_font;
                mask_div.style.color = defaultSettings.watermark_color;
                mask_div.style.textAlign = "center";
                mask_div.style.width = defaultSettings.watermark_width + 'px';
                mask_div.style.height = defaultSettings.watermark_height + 'px';
                mask_div.style.display = "block";
                oTemp.appendChild(mask_div);
            }
            ;
        }
        ;
        // $("#table").appendChild(oTemp);
        document.getElementById("table").appendChild(oTemp);
    }

}

function svg2canvas(targetElem) {
    var svgElem = targetElem.find('svg');
    svgElem.each(function (index, node) {
        var parentNode = node.parentNode;
        //由于现在的IE不支持直接对svg标签node取内容，所以需要在当前标签外面套一层div，通过外层div的innerHTML属性来获取
        var tempNode = document.createElement('div');
        tempNode.appendChild(node);
        var svg = tempNode.innerHTML;
        var canvas = document.createElement('canvas');
        //转换
        canvg(canvas, svg);
        parentNode.appendChild(canvas);
    });
}
